<template>
  <div class="add-personal">
    <van-nav-bar
      left-arrow
      class="title-bar"
      title="添加签约个人"
      :border="false"
      @click-left="$router.go(-1)"
    />
    <van-field
      v-model="recipien.operatorContact"
      center
      label="账号"
      placeholder="请输入手机/邮箱"
    >
      <van-icon
        slot="right-icon"
        class-prefix="iconfont iconmylianxiren"
        @click="$router.push('/frequent-contacts/' + 4)"
      ></van-icon>
    </van-field>
    <van-field
      v-model="recipien.operatorName"
      center
      label="姓名"
      placeholder="请输入真实姓名"
    />
    <!-- 个人实名 -->
    <van-cell class="autonym" center>
      <template #title>
        <span class="custom-title">个人实名</span>
        <span class="custom-content">(要求进行实名认证后才能签署)</span>
      </template>
      <template #right-icon>
        <van-switch v-model="recipien.PersonalName" size="1.5em" />
      </template>
    </van-cell>
    <!-- 刷脸校验 -->
    <van-cell class="autonym" center>
      <template #title>
        <span class="custom-title">刷脸校验</span>
        <span class="custom-content">(签署完要求进行刷脸意愿认证)</span>
      </template>
      <template #right-icon>
        <van-switch v-model="recipien.faceSwiping" size="1.5em" />
      </template>
    </van-cell>
    <!-- 手写签署 -->
    <van-cell class="autonym" center>
      <template #title>
        <span class="custom-title">手写签署</span>
        <span class="custom-content">(签署时要求手写签名)</span>
      </template>
      <template #right-icon>
        <van-switch v-model="recipien.writeSign" size="1.5em" />
      </template>
    </van-cell>
    <!-- 底部按钮 -->
    <div class="add-text-end">
      <van-button type="info" block @click="confirm">确定</van-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      recipien: {
        operatorContact: '',
        operatorName: '',
        PersonalName: true,
        faceSwiping: true,
        writeSign: true
      }
    }
  },
  created() {
    this.recipien.operatorContact = this.$route.params.phone
    this.recipien.operatorName = this.$route.params.realName
  },
  mounted() {},
  methods: {
    confirm() {
      if (this.recipien.operatorContact && this.recipien.operatorName) {
        const user = {
          recipientType: '2',
          orgName: '',
          operatorName: this.recipien.operatorName,
          operatorContact: this.recipien.operatorContact,
          operatorIdnumber: '',
          PersonalName: this.recipien.PersonalName,
          faceSwiping: this.recipien.faceSwiping,
          writeSign: this.recipien.writeSign
        }
        this.$store.commit('setAddresser', user)
        this.$router.push('ContractInformation')
      } else {
        this.$toast('必填项不能为空')
      }
    }
  }
}
</script>

<style scoped lang="less">
.add-personal {
  height: 100vh;
  position: relative;
  background-color: #f8f8f8;
  .title-bar {
    height: 128px;
    width: 100%;
    padding-top: 40px;
    box-sizing: border-box;
    margin-bottom: 20px;
    /deep/.van-nav-bar__title {
      font-size: 34px;
      font-weight: bold;
    }
    /deep/.van-icon {
      font-size: 48px;
      color: #000;
    }
  }
  .van-cell {
    height: 108px;
    /deep/.van-field__right-icon {
      color: #2489f2;
      .iconfont {
        font-size: 36px;
      }
    }
    /deep/.van-field__control {
      text-align: right;
    }
  }
  // 实名
  .autonym {
    margin-top: 20px;
    .custom-title {
      font-size: 30px;
      margin-right: 12px;
      color: #000;
    }
    .custom-content {
      font-size: 26px;
      color: #999999;
    }
  }
  // 底部
  .add-text-end {
    height: 136px;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    margin-top: 32px;
    padding: 20px 40px;
    box-sizing: border-box;
    background-color: #fff;
  }
}
</style>
